/*
Author:		Nguyen Anh Thoai
Email:		nathoai@gmail.com
Phone:		0985 029 516
Create:		28/10/2013 03:00 PM
Update:		?
--------------------------------------------------------------------------------------
Use Master;

If Exists(Select * From SysDatabases Where Name = 'QLNT')
	Drop Database QLNT;

Create Database QLNT
	Collate Vietnamese_Ci_Ai;
Go
Use QLNT;
Go

Set Dateformat Dmy
Go

*/

Use QLNT
Go

Create table Quan
(
	id			bigint			not null identity(1,1),
	ma			varchar(20)		null,
	ten			nvarchar(50)	null,
	Constraint pk_quan Primary Key(id)
)
GO

Create table Phuong
(
	id			bigint			not null identity(1,1),
	ma			varchar(20)		null,
	tenphuong	nvarchar(50)	null,
	quan_id		bigint			not null,
	Constraint pk_phuong Primary Key(id)
)
GO

Create table Duong
(
	id			bigint			not null identity(1,1),
	ma			varchar(20)		null,
	tenduong	nvarchar(50)	null,
	phuong_id		bigint		not null,
	Constraint pk_duong Primary Key(id)
)
GO

Create table Nhatro
(
	id			bigint			not null identity(1,1),
	ten			nvarchar(50)	null,
	chunha		nvarchar(50)	null,
	diachi		nvarchar(100)	null,
	dienthoai	varchar(15)		null,
	duong_id	bigint			not null,
	Constraint pk_nhatro Primary Key(id)
)
GO

Create table Phong
(
	id			bigint			not null identity(1,1),
	tenphong	nvarchar(50)	null,
	soluong		int				null,
	gia			decimal			null,
	nhatro_id	bigint			not null,
	Constraint pk_phong Primary Key(id)
)
GO

Create table Dongia
(
	id			bigint			not null identity(1,1),
	giadien		numeric(18,2)	null,
	gianuoc		numeric(18,2)	null,
	ngay		datetime		null,
	Constraint pk_Dongia Primary Key(id)
)
GO
